[SYCL] Differentiate install targets for clang* binaries#21598
Conversation
This patch renames `clang`, `clang++`, `clang-c++`, `clang-cc`, `clang-cpp`, `clang-g++`, `clang-gcc`, `clang-cl` to the same names with a prefix `dp` to make sure the SYCL compiler package can be co-existed with the official clang package for various Linux distributions.
|
|
||
| SmallString<128> ClangPath(C.getDriver().Dir); | ||
| llvm::sys::path::append(ClangPath, "clang"); | ||
| llvm::sys::path::append(ClangPath, "dpclang"); |
There was a problem hiding this comment.
We probably need to change sycl/doc as well
|
Thanks, @dm-vodopyanov. This is more change than I was expecting. How did you identify all the places to change? Trial and error by running the testsuite? Or a more systematic approach? |
dvrogozh
left a comment
There was a problem hiding this comment.
That's just a partial solution as it takes care to rename only clang* kind of things and leaves behind a bunch of lvm-* binaries, include/clang/, libLLVM*, etc. I would like to propose alternative solution which I hope will be easier:
- Change the install prefix for all the stuff borrowed from LLVM. Let default be
$libdir/dpclang-MAJOR/as that's prescribed default by File System Hierarchy Standard. This will immediately resolve all the potential conflicts with already installed LLVM. - Install additional targets, symlinks with the original names likes
dpclang-MAJOR
Above will create the following installation target (assuming the default for LLVM installation):
$bindir/dpclang ->$prefix/bin/dpclang-MAJOR
$bindir/dpclang-MAJOR
....
$libdir/libsycl.so.VERSION
$libdir/dpcpp-MAJOR/bin/clang
$libdir/dpcpp-MAJOR/bin/clang++
$libdir/dpcpp-MAJOR/bin/llvm-ar
...
|
I don't think this PR intended to solve the complete problem, I think it's just one piece of a larger set of changes. If we try to implement all of those in one PR it will become huge, impossible to review, and more likely to have bugs. |
I tend to agree with @dvrogozh's alternate suggestion. What he proposes is similar to what is done for the oneAPI icx compiler distribution (that distribution puts the LLVM utilities in a @dvrogozh, could you please quote the section of the File System Hierarchy Standard that you feel justifies placing the LLVM assets under |
It's section 4.6.1, https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s06.html: "/usr/lib includes object files and libraries. On some systems, it may also include internal binaries that are not intended to be executed directly by users or shell scripts. Applications may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the application must be placed within that subdirectory." Note that Debian's and Ubuntu's Also, to place internal stuff to |
clang* binaries
|
@dm-vodopyanov, I see the changes are currently marked Linux only. Can you confirm that is just temporary? My expectation is that the new targets will be provided on Windows as well. |
@dm-vodopyanov Can you please update these files with your latest commit (reverting the devicelib change)? Seeing the install dirs will greatly help my ability to review, thanks |
Yes, I'm actually working on this, building LLVM locally Upd.: updated the files |
sarnex
left a comment
There was a problem hiding this comment.
i am not an expert in this code either but overall lgtm, just some relatively minor comments
| /// Check "-fsycl-is-device" is passed when compiling for device: | ||
| // RUN: %clang -### -fsycl-device-only --no-offload-new-driver %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s | ||
| // CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}bin{{[/\\]+}}..{{[/\\]+}}include" |
There was a problem hiding this comment.
can you explain what the actual change in cc1 command is?
There was a problem hiding this comment.
The driver now derives the root via findSYCLInstallRoot(D), which normalizes the path (walks up and resolves), so bin/.. is collapsed out
| # actually exists rather than hardcoding a path that only works for one build | ||
| # layout. | ||
| foreach(path ${CMAKE_MODULE_PATH}) | ||
| if(EXISTS ${path}/LLVMInstallSymlink.cmake) |
There was a problem hiding this comment.
sorry i dont think my previous comment is resolved, do we really need to check the entire cmake_module_path, can we just use find_file?
There was a problem hiding this comment.
Should be resolved now, thanks
| # ld.lld/ld64.lld/lld-link/wasm-ld symlinks); redirect it too so the linkers | ||
| # don't collide with a system LLVM. The real lld binary destination is patched | ||
| # separately in lld/cmake/modules/AddLLD.cmake, mirroring add_clang_tool. | ||
| set(LLD_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) |
There was a problem hiding this comment.
Just wondering, I'm surprised we starting seeing a collision with system lld with this PR and need a workaround, any idea why?
There was a problem hiding this comment.
These binaries were in the main bin/ folder, so I moved them to lib/dpcpp-7/bin/ folder. Saw that only on Windows.
There was a problem hiding this comment.
Looking at the install-linux.txt and install-windows.txt files, it looks like lld is only built for Windows. Is that intentional?
There was a problem hiding this comment.
Looks like yes:
https://github.com/intel/llvm/blob/sycl/buildbot/configure.py#L160
# lld is needed on Windows or when building AMDGPU
Why this is true, I have no idea.
|
|
||
| if (LLD_BUILD_TOOLS) | ||
| # Install the real lld binary into the versioned DPC++ tools dir (e.g. | ||
| # lib/dpcpp-N/bin) so it doesn't conflict with a system LLVM, matching |
There was a problem hiding this comment.
Installing lld binary to lib sub-directory doesn't make sense to me. Please, fix the comment (and implementation if needed).
There was a problem hiding this comment.
The request was to keep only DPC++-related binaries in bin/ folder.
There was a problem hiding this comment.
Please, put binaries to bin sub-directory (e.g. bin/llvm-bin/).
There was a problem hiding this comment.
There may be concerns from Canonical - "llvm-bin" is too basic name, for our compiler we need customizations. Also I don't know the whole story but looks like we can't use bin/ folder for that. So @dvrogozh suggested to use lib/dpcpp-N/bin.
+ @tahonermann for opinions
There was a problem hiding this comment.
lib is for libraries. bin is for binaries.
Putting binaries to lib sub-directory if we can put them into bin sub-directory doesn't make sense.
Intel oneAPI puts llvm binaries to bin/compiler directory to address the conflict with LLVM package.
There was a problem hiding this comment.
Do we really need to have dp* links for sycl-* tools? I don't think LLVM packages include sycl-* tools.
There was a problem hiding this comment.
IMO it's useful for user experience to teach users stuff starting with dp is from intel's sycl compiler
There was a problem hiding this comment.
Future LLVM packages will include a sycl-ls utility. The DPC++ package that Canonical will be distributing includes the SYCL utilities with a dp prefix, so this is consistent.
There was a problem hiding this comment.
Future LLVM packages will include a sycl-ls utility.
I'm not sure if distributing sycl-* tools as LLVM package is a good idea. I would prefer to have a separate package for them.
There was a problem hiding this comment.
I think the sycl-* utilities should be part of the LLVM project. How Linux distributors package them is up to them of course, but we can encourage them to place them in a separate package. They may opt to do so anyway. The Canonical package includes dpsycl-ls with dpclang and the other dp prefixed utilities in the dpclang package.
sarnex
left a comment
There was a problem hiding this comment.
lgtm, just one comment, nice!
|
Failure in SYCL Benchmarks is unrelated: #22599 |
No more changes in upstream files -> I'm happy.
…22603) This PR adds the following: * The following symlinks in `CMAKE_INSTALL_PREFIX/bin` folder: `dpclang`, `dpclang++`, `dpclang-cl`, `dpclang-cpp`, `dpsycl-ls`, `dpsycl-prof`, etc. They WON'T point to real `clang`, `clang++`, etc binaries. They point to the tool below. * Adds a tool similar to AMD's `amdllvm` tool: https://github.com/ROCm/llvm-project/tree/amd-staging/clang/tools/amdllvm. It is called `dpllvm`. What it does - when we run `dpclang++` symlink, it runs `dpllvm` tool. `dpllvm` gets "clang++" from "dpclang++" and executes `clang++`. The same will be with every other symlinks which start wqith `dp`. `clang` can run itself inside itself, so we need to keep the name of the binary - `clang++`. BTW, the same on Windows - but we will have tiny binaries `dpclang`, `dpclang++`, etc - as Windows does not support symlinks. So we will avoid renaming `clang++` to `dpclang++` on Windows and the size of binary distribution on Windows won't be bigger - there won't be copies of `clang`, `clang-cl`, etc binaries. * Adds `dpllvm` and `dpclang`, `dpclang++`, `dpclang-cl`, `dpclang-cpp`, `dpsycl-ls`, `dpsycl-prof`, etc. not only to `CMAKE_INSTALL_PREFIX/bin` but also to `build/bin` - and use these binaries everywhere in LIT tests (like it is already done in this PR) Fixes #21511 --------- --------- Co-authored-by: dmitry.vodopyanov <dvodopya@smtp.igk.intel.com>
This PR adds the following:
CMAKE_INSTALL_PREFIX/binfolder:dpclang,dpclang++,dpclang-cl,dpclang-cpp,dpsycl-ls,dpsycl-prof, etc. They WON'T point to realclang,clang++, etc binaries. They point to the tool below.amdllvmtool: https://github.com/ROCm/llvm-project/tree/amd-staging/clang/tools/amdllvm. It is calleddpllvm. What it does - when we rundpclang++symlink, it runsdpllvmtool.dpllvmgets "clang++" from "dpclang++" and executesclang++. The same will be with every other symlinks which start wqithdp.clangcan run itself inside itself, so we need to keep the name of the binary -clang++. BTW, the same on Windows - but we will have tiny binariesdpclang,dpclang++, etc - as Windows does not support symlinks. So we will avoid renamingclang++todpclang++on Windows and the size of binary distribution on Windows won't be bigger - there won't be copies ofclang,clang-cl, etc binaries.dpllvmanddpclang,dpclang++,dpclang-cl,dpclang-cpp,dpsycl-ls,dpsycl-prof, etc. not only toCMAKE_INSTALL_PREFIX/binbut also tobuild/bin- and use these binaries everywhere in LIT tests (like it is already done in this PR)Fixes #21511